package cn.zyq.charging.order.mqtt;

import cn.zyq.charging.order.dao.mapper.OrderFailMapper;
import cn.zyq.charging.order.dao.mapper.OrderSuccessMapper;
import cn.zyq.charging.order.dao.repository.ChargingProcessRepository;
import cn.zyq.charging.order.dao.repository.OrderRepository;
import cn.zyq.charging.order.feign.CostClient;
import cn.zyq.charging.order.feign.UserClient;
import cn.zyq.charging.order.service.OrderService;
import cn.zyq.charging.order.webSocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 本类MqttContext是需要传入到MqttConsumer类中构造方法中的(MqttConsumer需要调用MqttContext中封装的其他对象)
 * 封装订单生成成功的Mapper和订单失败的的Mapper以及OpenFeign组件调用user模块的对象UserClient
 * 为了避免MqttConsumer的构造方法参数过多(有时还会给此类的构造方法不断添加参数)，
 * 就使用MqttContext封装多个有可能被MqttConsumer类使用的对象(比如orderSuccessMapper)。
 */
@Component
public class MqttContext {
    @Autowired(required = false)
    private OrderRepository orderRepository;

    //@Autowired//订单成功的持久层接口  (重新封装到OrderRepository接口的实现类中了)
    //private OrderSuccessMapper orderSuccessMapper;

    //@Autowired//订单失败的持久层接口 (重新封装到OrderRepository接口的实现类中了)
    //OrderFailMapper orderFailMapper;

    @Autowired(required = false)
    private ChargingProcessRepository chargingProcessRepository;


    /**通过OpenFeign调用计费服务的计费服务接口CostClient*/
    @Autowired(required = false)
    private CostClient costClient;

    @Autowired
    private UserClient userClient;


    public ChargingProcessRepository getChargingProcessRepository() {
        return chargingProcessRepository;
    }
    @Autowired
    private WebSocketServer webSocketServer;

    public WebSocketServer getWebSocketServer() {
        return webSocketServer;
    }

    /*public OrderSuccessMapper getOrderSuccessMapper() {
        return orderSuccessMapper;
    }

    public OrderFailMapper getOrderFailMapper() {
        return orderFailMapper;
    }*/

    public UserClient getUserClient() {
        return userClient;
    }

    /*public CostClient getCostClient() {
        return costClient;
    }*/

    public OrderRepository getOrderRepository() {
        return orderRepository;
    }

    public CostClient getCostClient() {
        return costClient;
    }
}
